using AiQiuQuan.Sport.Model.Enums;
using System.ComponentModel.DataAnnotations;

namespace AiQiuQuan.Sport.Model.Models
{
    /// <summary>
    /// 新增广告dto
    /// </summary>
    public class AdvertisementAddDto : IValidatableObject
    {
        /// <summary>
        /// 广告名称
        /// </summary>
        [Required(AllowEmptyStrings = false, ErrorMessage = "广告名称必填")]
        [StringLength(100, ErrorMessage = "广告名称不能超过100个字符")]
        public string Name { get; set; }

        /// <summary>
        /// 广告内容
        /// </summary>
        [StringLength(300, ErrorMessage = "广告内容不能超过300个字符")]
        public string? Content { get; set; }

        /// <summary>
        /// 广告URL
        /// </summary>
        [StringLength(200, ErrorMessage = "广告URL不能超过200个字符")]
        public string? Url { get; set; }

        /// <summary>
        /// 省
        /// </summary>
        public Guid? ProvinceId { get; set; }

        /// <summary>
        /// 市
        /// </summary>
        public Guid? CityId { get; set; }

        /// <summary>
        /// 业务类型：1 场馆场地、5 活动、6 约球、10 比赛、11 课程、12 私教
        /// </summary>
        [Required(ErrorMessage = "业务类型：1 场馆场地、5 活动、6 约球、10 比赛、11 课程、12 私教必填")]
        [EnumDataType(typeof(BusinessTypeEnum))]
        public BusinessTypeEnum BusinessType { get; set; }

        /// <summary>
        /// 广告类型：1banner、2advert
        /// </summary>
        [Required(ErrorMessage = "广告类型：1banner、2advert必填")]
        [EnumDataType(typeof(AdvertTypeEnum))]
        public AdvertTypeEnum Type { get; set; }

        /// <summary>
        /// 动作类型：0不跳转、1url、2微信小程序
        /// </summary>
        [Required(ErrorMessage = "动作类型：0不跳转、1url、2微信小程序必填")]
        [EnumDataType(typeof(AdvertActionTypeEnum))]
        public AdvertActionTypeEnum ActionType { get; set; }

        /// <summary>
        /// 跳转URl
        /// </summary>
        public string? ActionUrl { get; set; }

        /// <summary>
        /// appid
        /// </summary>
        [StringLength(100, ErrorMessage = "appid不能超过100个字符")]
        public string? AppId { get; set; }

        /// <summary>
        /// 赞助商
        /// </summary>
        [StringLength(100, ErrorMessage = "赞助商不能超过100个字符")]
        public string? Sponsor { get; set; }

        /// <summary>
        /// 赞助商电话
        /// </summary>
        [StringLength(30, ErrorMessage = "赞助商电话不能超过30个字符")]
        public string? SponsorTel { get; set; }

        /// <summary>
        /// 赞助商logo
        /// </summary>
        [StringLength(200, ErrorMessage = "赞助商logo不能超过200个字符")]
        public string? SponsorLogo { get; set; }

        /// <summary>
        /// validate
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (CityId.HasValue && !ProvinceId.HasValue)
            {
                yield return new ValidationResult("省为空");
                yield break;
            }
        }
    }
}
